"""
@File    : RunMain.py
@Time    : 2019/7/15 17:13
@Author  : LiuFeiYu
@Email   : liufeiyu@sunrise.net
@Software: PyCharm
"""
import sys
import pytest
from Common import LogCof
from Common import Shell
from Settings import Config

if __name__ == '__main__':
    conf = Config.Config()
    log = LogCof.MyLog()
    log.info_msg('初始化配置文件, path=' + conf.conf_path)

    shell = Shell.Shell()
    xml_report_path = conf.xml_report_path
    html_report_path = conf.html_report_path

    # 定义测试集
    allure_list = '--allure_features=test-name'

    args = ['-s', '-q', '--alluredir', xml_report_path]
    log.info_msg('执行用例集为：%s' % allure_list)
    # self_args = sys.argv[1:]
    pytest.main(args)
    cmd = 'allure generate %s -o %s' % (xml_report_path, html_report_path)
    try:
        shell.invoke(cmd)
    except Exception:
        log.error_msg('执行用例失败，请检查环境配置')
        raise
